﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using AppLayer;

namespace GUI
{
	public partial class Entry : Form
	{
		LogIn myLogin;
		Admin myAdmin;
		GamePlay myGame;
		Desinger myDesinger;
		AboutBox myAboutBox;
		HighScores myHighScores;

		private UserAccount.UserType _myUser;

		public UserAccount.UserType MyUser
		{
			get
			{
				return _myUser;
			}
			set
			{
				_myUser = value;
			}
		}

		public Entry()
		{
			InitializeComponent();
			copyRightLable.Text = "\u00a9 Clayton Reeves && Nate Wong";
		}

		void myLogin_UserAuthenticated(UserAccount.UserType type)
		{
			SetLoginType(type);
		}

		private void SetLoginType(UserAccount.UserType type)
		{
			switch (type)
			{
				case UserAccount.UserType.Normal:
					designButton.Enabled = false;
					adminButton.Enabled = false;
					break;
				case UserAccount.UserType.Designer:
					designButton.Enabled = true;
					adminButton.Enabled = false;
					break;
				case UserAccount.UserType.Admin:
					designButton.Enabled = true;
					adminButton.Enabled = true;
					break;
				default:
					designButton.Enabled = false;
					adminButton.Enabled = false;
					break;
			}
		}

		private void playButton_Click(object sender, EventArgs e)
		{
			myGame = new GamePlay();
			this.Hide();
			myGame.Show(this);
		}

		private void designButton_Click(object sender, EventArgs e)
		{
			myDesinger = new Desinger();
			this.Hide();
			myDesinger.Show(this);
		}

		private void adminButton_Click(object sender, EventArgs e)
		{
			myAdmin = new Admin();
			myAdmin.ShowDialog(this);
		}

		private void aboutButton_Click(object sender, EventArgs e)
		{
			myAboutBox = new AboutBox();
			myAboutBox.ShowDialog(this);
		}

		private void scoreButton_Click(object sender, EventArgs e)
		{
			myHighScores = new HighScores();
			myHighScores.ShowDialog(this);
		}

		private void loginButton_Click(object sender, EventArgs e)
		{
			myLogin = new LogIn();
			myLogin.UserAuthenticated += new LogIn.UserAuthenticationEventHandler(myLogin_UserAuthenticated);
			//TODO: set up for the login screen
			myLogin.ShowDialog(this);

		}

		private void button1_Click(object sender, EventArgs e)
		{
			this.Close();
		}
	}
}
